package com.huang.entity.result;


import java.util.Collections;
import java.util.List;

/**
 * 响应结果
 */
public class ResultBuilder {
    private ResultBuilder() {
    }

    public static <T> HStringResult<T> failHSingle(ResponseEnum responseEnum) {
        HStringResult<T> thStringResult = new HStringResult<>();
        thStringResult.setCode(responseEnum.getCode());
        thStringResult.setMsg(responseEnum.getMsg());
        thStringResult.setData(null);
        return thStringResult;
    }
    public static <T> HStringResult<T> failHSingle(ResponseEnum responseEnum,String msg) {
        HStringResult<T> thStringResult = new HStringResult<>();
        thStringResult.setCode(responseEnum.getCode());
        thStringResult.setMsg(msg);
        thStringResult.setData(null);
        return thStringResult;
    }

    public static <T> HStringResult<T> failHSingle(String msg) {
        HStringResult<T> thStringResult = new HStringResult<>();
        thStringResult.setCode(ResponseEnum.SERVICE_ERROR.getCode());
        thStringResult.setMsg(msg);
        thStringResult.setData(null);
        return thStringResult;
    }

    public static <T> HStringResult<T> failHSingle() {
        HStringResult<T> thStringResult = new HStringResult<>();
        thStringResult.setCode(ResponseEnum.SERVICE_ERROR.getCode());
        thStringResult.setMsg(ResponseEnum.SERVICE_ERROR.getMsg());
        thStringResult.setData(null);
        return thStringResult;
    }


    public static <T> HStringResult<T> successHSingleMsg(String msg) {
        HStringResult<T> thStringResult = new HStringResult<>();
        thStringResult.setCode(ResponseEnum.SUCCESS.getCode());
        thStringResult.setMsg(msg);
        thStringResult.setData(null);
        return thStringResult;
    }

    public static <T> HStringResult<T> successHSingle() {
        HStringResult<T> thStringResult = new HStringResult<>();
        thStringResult.setCode(ResponseEnum.SUCCESS.getCode());
        thStringResult.setMsg(ResponseEnum.SUCCESS.getMsg());
        thStringResult.setData(null);
        return thStringResult;
    }

    public static <T> HStringResult<T> successHSingle(T data) {
        HStringResult<T> thStringResult = new HStringResult<>();
        thStringResult.setCode(ResponseEnum.SUCCESS.getCode());
        thStringResult.setMsg(ResponseEnum.SUCCESS.getMsg());
        thStringResult.setData(data);
        return thStringResult;
    }

    public static <T> HPageResult<T> successHPage(List<T>  data, HPage page) {
        HPageResult<T> thPageResult = new HPageResult<>();
        thPageResult.setPage(page);
        thPageResult.setCode(ResponseEnum.SUCCESS.getCode());
        thPageResult.setMsg(ResponseEnum.SUCCESS.getMsg());
        thPageResult.setData(data);
        return thPageResult;
    }

    public static <T> HPageResult<T> successHPage(List<T> data, HPage page, ResponseEnum responseEnum) {
        HPageResult<T> thPageResult = new HPageResult<>();
        thPageResult.setPage(page);
        thPageResult.setCode(responseEnum.getCode());
        thPageResult.setMsg(responseEnum.getMsg());
        thPageResult.setData(data);
        return thPageResult;
    }

    public static <T> HPageResult<T> failHPage(ResponseEnum responseEnum) {
        HPageResult<T> thPageResult = new HPageResult<>();
        thPageResult.setCode(responseEnum.getCode());
        thPageResult.setMsg(responseEnum.getMsg());
        thPageResult.setData(null);
        return thPageResult;
    }

    public static HPageResult<String> failHPage() {
        HPageResult<String> thPageResult = new HPageResult<>();
        thPageResult.setCode(ResponseEnum.SUCCESS.getCode());
        thPageResult.setMsg(ResponseEnum.SUCCESS.getMsg());
        thPageResult.setData(null);
        return thPageResult;
    }

    public static <T> HPageResult<T> failHPage(String msg) {
        HPageResult<T> thPageResult = new HPageResult<>();
        thPageResult.setCode(ResponseEnum.SERVICE_ERROR.getCode());
        thPageResult.setMsg(msg);
        thPageResult.setData(null);
        return thPageResult;
    }


    public static <T> HCollectionResult<T> failHSCollection(ResponseEnum responseEnum) {
        HCollectionResult<T> cResult = new HCollectionResult<>();
        cResult.setCode(responseEnum.getCode());
        cResult.setMsg(responseEnum.getMsg());
        cResult.setData(Collections.emptyList());
        return cResult;
    }

    public static <T> HCollectionResult<T> failHSCollection() {
        HCollectionResult<T> cResult = new HCollectionResult<>();
        cResult.setCode(ResponseEnum.SERVICE_ERROR.getCode());
        cResult.setMsg(ResponseEnum.SERVICE_ERROR.getMsg());
        cResult.setData(Collections.emptyList());
        return cResult;
    }

    public static <T> HCollectionResult<T> successHSCollection(List<T> data) {
        HCollectionResult<T> cResult = new HCollectionResult<>();
        cResult.setCode(ResponseEnum.SUCCESS.getCode());
        cResult.setMsg(ResponseEnum.SUCCESS.getMsg());
        cResult.setData(data);
        return cResult;
    }



}
